<?php

namespace app\index\controller;

use app\index\model\Banner as BannerModel;
use think\Request;
use app\index\model\Product as ProductModel;

class Product extends BaseController
{
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $banner = BannerModel::getBanner('social');
        $action = $request->action();
        $this->assign('banner', $banner);
        $this->assign('action', $action);
    }

    /**
     * 产品介绍
     */
    public function lists()
    {
        $lists = ProductModel::getLists();
        $this->paginate($lists->lastPage(), $lists->currentPage());
        $this->assign('lists', $lists);
        return $this->fetch();
    }

    /**
     * 产品详情
     */
    public function detail($id = 0)
    {
        $product = ProductModel::getById($id);
        $preId = ProductModel::getPreId($id);
        $nextId = ProductModel::getNextId($id);
        $this->assign('preId', $preId);
        $this->assign('nextId', $nextId);
        $this->assign('product', $product);
        return $this->fetch();
    }

}
